import config from './config';

export default util = {
  getThumbImageHeight: (imageCount) => {
    switch(imageCount) {
      case 1:
      case 2:
        return 150;
      default:
        return 100;
    }
  },
  getThumbImageUrl: (key, width = null, height = null) => {
    let options = "";
    if (width || height) {
      options += '?imageView2/0';
      if (width) {
        options += '/w/' + width;
      }
      if (height) {
        options += '/h/' + height;
      }
    }
    return config.attachment_base_uri + key + options;
  },
  getRequestOption: async (method = "GET") => {
    // let tokenData = await AsyncStorage.getItem(Config.token_key);
    let tokenData = null;
    console.log("getRequestOption, tokenData: ", tokenData);
    let token = config.default_token;
    if (tokenData) {
      tokenData = JSON.parse(tokenData);
      token = tokenData.access_token;
    }
    return {
      method: method,
      headers: {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": "Bearer " + token,
      },
    }
  }
}



